<template>
    <div class="food" v-show="isShow">
        <div class="food-content">
            <div class="image-header">
                <img
                    :src="food.coverImg">
                <p class="foodpanel-desc">{{food.shopIntroduction}}</p>
                <div class="back" @click="toggleShow">
                    <i class="iconfont icon-zuo"></i>
                </div>
            </div>
            <div class="content">
                <h1 class="title">{{food.shopName}}</h1>
                <!-- <div class="detail"> -->
                    <!-- <span class="sell-count">月售 {{food.sellCount}} 份</span>
                    <span class="rating">好评率 {{food.rating}}%</span> -->
                <!-- </div> -->
                <div class="price">
                    <span class="now">￥{{food.originalPrice}}</span>
                    <span class="old" v-show="food.oldPrice">￥{{food.oldPrice}}</span>
                </div>
                <div class="cartcontrol-wrapper">
                    <CartControl :food="food"/>
                </div>
            </div>
        </div>
        <div class="food-cover" @click="toggleShow"></div>
    </div>
</template>

<script>
import CartControl from "../CartControl/CartControl.vue";

export default {
  data() {
    return {
      isShow: false
    };
  },
  props: {
    food: Object
  },
  methods: {
    toggleShow() {
      this.isShow = !this.isShow;
    }
  },
  components: {
    CartControl
  }
};
</script>

<style lang="scss" scoped>
.food {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 55px;
  width: 100%;
  z-index: 20;
  &.fade-enter-active,
  &.fade-leave-active {
    transition: opacity 0.5s;
  }
  &.fade-enter,
  &.fade-leave-to {
    opacity: 0;
  }
  .food-content {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    width: 80%;
    height: 65%;
    border-radius: 5px;
    overflow: hidden;
    z-index: 40;
    .image-header {
      position: relative;
      width: 100%;
      height: 0;
      padding-top: 100%;
      img {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
      }
      .foodpanel-desc {
        font-size: 10px;
        color: #ddd;
        position: absolute;
        bottom: -12px;
        left: 12px;
      }
      .back {
        position: absolute;
        left: 5px;
        top: 5px;
        color: #fff;
        .icon-zuo {
          font-size: 20px;
        }
      }
    }
    .content {
      position: relative;
      padding: 18px;
      .title {
        line-height: 14px;
        font-size: 24px;
        margin-bottom: 8px;
        font-weight: 700;
        color: rgb(7, 17, 27);
      }
      .detail {
        margin-top: 18px;
        line-height: 10px;
        height: 10px;
        font-size: 12px;
        .sell-count,
        .rating {
          font-size: 10px;
          color: rgb(147, 153, 159);
          margin-right: 12px;
        }
      }
      .price {
        font-weight: 700;
        line-height: 24px;
        margin-top: 10px;
        .now {
          margin-right: 8px;
          font-size: 16px;
          color: rgb(240, 20, 20);
        }
        .old {
          text-decoration: line-through;
          font-size: 10px;
          color: rgb(147, 153, 159);
        }
      }
      .cartcontrol-wrapper {
        position: absolute;
        right: 12px;
        bottom: 20px;
      }
    }
  }
  .food-cover {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    background-color: rgb(0, 0, 0, 0.5);
    z-index: 30;
  }
}
</style>
